package tests;

import tester.*;

/**
 * Copyright 2007, 2008 Viera K. Proulx
 * This program is distributed under the terms of the 
 * GNU Lesser General Public License (LGPL)
 */
/**
 * <p>A class that illustrates the ease of transition from ProfessorJ to 
 * using the <code>tester</code> library.</p>
 * <p>The class contains only the desired test cases.</p>
 * <p>Run it with the file <code>ILoS</code>
 */
@Example
class AnyExamples{
  
  // * Examples, Songs and ILoSs *
  Song help = new Song("Help", "Beatles", 50, 0.99);
  Song dsotm = new Song("Dsotm", "Pink Floyd", 100, 0.25);
  Song hts = new Song("Hts", "Muse", 10, 0.90);

  ILoS mtlos = new MtLoS();
  ILoS list1 = new ConsLoS(this.help, this.mtlos);
  ILoS list2 = new ConsLoS(this.dsotm, new ConsLoS( this.hts, this.list1));

  // *  Test the method count in the classes for lists of Song-s
  @TestMethod
  boolean testCount(Tester t){
    return t.checkExpect(this.mtlos.count(), 0) &&
           t.checkFail(this.list1.count(), /*1*/ 3) &&   // will fail
           t.checkExpect(this.list2.count(), 3);  
  }

  
  // *  Test the method totalSize in the classes for lists of Song-s
  @TestMethod
  boolean testTotalSize(Tester t){
    return t.checkExpect(this.mtlos.totalSize(), 0) &&
           t.checkExpect(this.list1.totalSize(), 50) &&
           t.checkFail(this.list2.totalSize(), /*160*/ 150);  // will fail
  }

  // * Test the method contains in the classes for lists of Song-s
  @TestMethod
  boolean testContains(Tester t){
    return t.checkExpect(this.mtlos.contains("Beatles"), false) &&
           t.checkExpect(this.list1.contains("Beatles"), true) &&
           t.checkExpect(this.list1.contains("Muse"), false) &&
           t.checkFail(this.list2.contains("Muse"), false) && //fail
           t.checkExpect(this.list2.contains("ABC"), false);
  }

  // * Test the method allBy in the classes for lists of Song-s
  @TestMethod
  boolean testAllBy(Tester t){
    return t.checkExpect(this.mtlos.allBy("Pink Floyd"), this.mtlos) &&
           t.checkExpect(this.list1.allBy("Pink Floyd"), this.mtlos) &&
           t.checkExpect(this.list1.allBy("Beatles"), this.list1) &&
           t.checkExpect(this.list2.allBy("Pink Floyd"), 
                  new ConsLoS(this.dsotm, this.mtlos)) &&
           t.checkExpect(this.list2.allBy("Beatles"), this.list1);
  }

}